<?php
/**
 * 公众号页卡券相关接口
 * @author lss
 * 2017-06-13
 */
namespace soa\cloudPrint\v1;

use soa\client;

class CloudPrint  extends client
{
    /**
     * 服务地址
     * @var string
     */
    public $service_url = 'http://cloud-print.interface.kuaidihelp.com';

    /**
     * 服务名称
     * @var string
     */
    protected $service_name = 'kuaidihelp_cloud_print';

	//打印订单
	public function printOrder($openid,$orderInfo,$agentId,$batch = "false",$user_id = "51666"){
		return $this->post("/v1/CloudPrint/print",[
			"agent_id" => $agentId,
			"uid" => $openid,
			"batch" => $batch,
			"data" => is_array($orderInfo) ? json_encode($orderInfo) : $orderInfo,
			"app_id" => $user_id,
			"user_id" => $user_id,
		]);
	}

	//打印订单清单
	public function printOrderList($openid,$taskId,$data,$agentId,$batch = "false",$user_id = "51666"){
		return $this->post("/v1/CloudPrint/print",[
			"taskId" => $taskId,
			"agent_id" => $agentId,
			"uid" => $openid,
			"batch" => $batch,
			"data" => is_array($data) ? json_encode($data) : $data,
			"type" => "std_xml_file",
			"app_id" => $user_id,
			"user_id" => $user_id,
		]);
	}

	//agent迁移
	public function migratePrinterAgent($sceneId,$agentId,$user_id = "51666"){
		return $this->post("/v1/CloudPrint/migratePrinterAgent",[
			"token" => $sceneId,
			"agent_id" => $agentId,
			"user_id" => $user_id,
		]);
	}

	//获取agent信息
	public function agentInfo($agentId,$user_id = "51666"){
		return $this->post("/v1/CloudPrint/agentInfo",[
			"agent_id" => $agentId,
			"user_id" => $user_id,
		]);
	}

	//根据打印机的秘钥获取打印机信息
	public function getAgentInfoBySecret($secret,$user_id = "51666"){
		return $this->post("/v1/CloudPrint/agentInfo",[
			"agent_key" => $secret,
			"user_id" => $user_id,
		]);
	}

	//获取打印任务信息
	public function getPrintTaskInfo($taskId,$user_id = "51666"){
		return $this->post("/v1/CloudPrint/taskInfo",[
			"task_id" => $taskId,
			"user_id" => $user_id,
			"app_id" => $user_id,
		]);
	}

	//删除管理员
	public function deleteManager($agentId,$uid,$user_id = "51666"){
		return $this->post("/v1/CloudPrint/deleteManager",[
			"agent_id" => $agentId,
			"uid" => $uid,
			"user_id" => $user_id,
		]);
	}

	//获取模板列表
	public function templateList($params,$user_id = "51666"){
		return $this->post("/v1/CloudPrint/templateList",[
			"page" => $params["page_num"] ? : 1,
			"limit" =>  $params["page_size"] ? : 100,
			"user_id" => $user_id,
			"brand_code" => $params["brand_code"] ? : "",
		]);
	}

	//获取模板详情
	public function templateInfo($templateId,$user_id = "51666"){
		return $this->post("/v1/CloudPrint/templateInfo",[
			"template_id" => $templateId,
			"user_id" => $user_id,
		]);
	}
}